local UITeamsRename     = UIBase.New(PanelResNames.UITeamsRename)

local m_team            = {}

function UITeamsRename.Init(tb)
    m_team = tb
    UIBase.Init(UITeamsRename)
end

function UITeamsRename:OnCreate()
    self:RegisterOnClick(self:GetChild("black"), self.onClick_cancle)
    self:RegisterOnClick(self:GetChild("start"), self.onClick_confirm)

    self.inputName = self:GetChild("inputName")
    self.inputName.maxLength = GetGlobalIntValue(563)
end

function UITeamsRename:OnDestroy()
    
end

function UITeamsRename:onClick_cancle()
    closeUI(PanelResNames.UITeamsRename)
end

function UITeamsRename:onClick_confirm()
    if self.inputName.text then
        local index = FormationManager.GetFocus()
        if self.inputName.text == "" then
            UISysTips.AddMsg(getLanguage("Sys_MsgInputEmpty"))
        else
            if logicMgr.ChatManager.HasFilterBlockWord(self.inputName.text) then
                UISysTips.AddMsg(getLanguage("UIFriend_ApplyMsgBlock"))
            else
                FormationManager.req_RenameFormation(m_team.index, self.inputName.text)
            end
            self:onClick_cancle()
        end
    end
end

return UITeamsRename